"use client"

import { Button } from "@/components/ui/button"
import { Home, FolderOpen, FileText, Database, FileOutput, Users, Settings, Palette, LogOut } from "lucide-react"
import type { ActiveTab } from "@/app/page"

interface SidebarProps {
  activeTab: ActiveTab
  onTabChange: (tab: ActiveTab) => void
}

export default function Sidebar({ activeTab, onTabChange }: SidebarProps) {
  const menuItems = [
    { id: "main" as ActiveTab, label: "主界面", icon: Home },
    { id: "projects" as ActiveTab, label: "项目管理", icon: FolderOpen },
    { id: "templates" as ActiveTab, label: "模板管理", icon: FileText },
    { id: "data" as ActiveTab, label: "数据管理", icon: Database },
    { id: "results" as ActiveTab, label: "结果管理", icon: FileOutput },
  ]

  return (
    <div className="w-64 border-r bg-muted/10 flex flex-col">
      {/* 登录状态区 */}
      <div className="h-16 p-4 border-b flex items-center justify-between">
        <div className="flex items-center gap-2">
          <div className="h-8 w-8 rounded-full bg-primary flex items-center justify-center text-primary-foreground text-sm font-medium">
            用
          </div>
          <span className="font-medium">管理员</span>
        </div>
        <Button variant="ghost" size="sm" className="text-muted-foreground">
          <LogOut className="h-4 w-4 mr-1" />
          注销
        </Button>
      </div>

      {/* 标签页区域 */}
      <div className="flex-1 p-4">
        <nav className="space-y-2">
          {menuItems.map((item) => {
            const Icon = item.icon
            return (
              <Button
                key={item.id}
                variant={activeTab === item.id ? "secondary" : "ghost"}
                className="w-full justify-start"
                onClick={() => onTabChange(item.id)}
              >
                <Icon className="mr-2 h-4 w-4" />
                {item.label}
              </Button>
            )
          })}
        </nav>
      </div>

      {/* 系统设置栏 */}
      <div className="h-32 p-4 border-t">
        <div className="space-y-2">
          <Button
            variant={activeTab === "users" ? "secondary" : "ghost"}
            className="w-full justify-start"
            onClick={() => onTabChange("users")}
          >
            <Users className="mr-2 h-4 w-4" />
            用户管理
          </Button>
          <Button variant="ghost" className="w-full justify-start">
            <Settings className="mr-2 h-4 w-4" />
            系统设置
          </Button>
          <Button variant="ghost" className="w-full justify-start">
            <Palette className="mr-2 h-4 w-4" />
            UI选择
          </Button>
        </div>
      </div>
    </div>
  )
}
